import { reqCategoryList, mockReqBannerList, mockReqFloorList} from '@/api'
const state = {
    // state内的数据初始值 需要根据获取过来的数据的根结构而定 千万不能瞎写
    categoryList: [],
    getBannerList: [],
    getFloorList:[]
}
const mutations = {
    CATEGORYLIST(state, categoryList) {
        state.categoryList = categoryList
    },
    GETBANNERLIST(state, bannerList) {
        state.getBannerList = bannerList
    },
    GETFLOORLIST(state,floorList){
        state.getFloorList = floorList

    }
}
const actions = {
    // 此出commit是结构countext这个上下文参数得来
    async categoryList({ commit }) {
        let result = await reqCategoryList()
        if (result.code === 200) {
            commit('CATEGORYLIST', result.data)
          
        }

    },
    async getBannerList({ commit }) {
        let result = await mockReqBannerList()
        if (result.code === 200) {
            commit('GETBANNERLIST',result.data)
          

        }

    },
    async getFloorList({ commit }) {
        let result = await mockReqFloorList()
        if (result.code === 200) {
            commit('GETFLOORLIST',result.data)
           

        }

    }

}
const getters = {}
export default {
    state,
    mutations,
    actions,
    getters,

}